package com.yunfei.yunhetong.elecContBeneAcctDtl.service.impl;
import java.util.*;
import com.yunfei.utils.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.yunfei.utils.BaseException;
import com.yunfei.utils.log.BaseLog;
import com.yunfei.utils.string.StringUtil;
import com.yunfei.utils.id.IdUtils;
import com.yunfei.mapper.aiiidb.ElecContBeneAcctDtlMapper;
import com.yunfei.yunhetong.elecContBeneAcctDtl.bo.*;
import com.yunfei.yunhetong.elecContBeneAcctDtl.entity.*;
import com.yunfei.yunhetong.elecContBeneAcctDtl.service.*;
import com.yunfei.yunhetong.elecContBeneAcctDtl.service.impl.*;
   /**
    *@tablename eleccontbeneacctdtl
    *@author zhengyunfei
    *@createDate Wed Aug 28 17:25:21 CST 2019
    */ 
	@Service("eleccontbeneacctdtlService")
	public class ElecContBeneAcctDtlServiceImpl implements ElecContBeneAcctDtlService{
	@Autowired
	private ElecContBeneAcctDtlMapper elecContBeneAcctDtlMapper;
	/**
	*新增
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public String add(ElecContBeneAcctDtlBo bo){
	String backInfo="保存成功";
	String id="";
		try{
			ElecContBeneAcctDtlEntity entity=ElecContBeneAcctDtlBo.boToEntity(bo);
			id= IdUtils.getId();
			elecContBeneAcctDtlMapper.add(entity);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "add 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return id;
}
	/**
	*新增
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public String batchInsert(List list){
	String backInfo="保存成功";
	String id="";
		try{
			elecContBeneAcctDtlMapper.add(list);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "batchInsert 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return id;
}
	/**
	*修改
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public String update(ElecContBeneAcctDtlBo bo){
	String backInfo="修改成功";
		try{
			ElecContBeneAcctDtlEntity entity=ElecContBeneAcctDtlBo.boToEntity(bo);
			elecContBeneAcctDtlMapper.update(entity);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "update更新失败", e);
			 throw new BaseException("更新！",e);
		}
		return backInfo;
}
	/**
	*删除
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public String delete(String id){
	String backInfo="删除成功";
		try{
			Map<String,Object> map=new HashMap<String, Object>();
			map.put("id",id.split(","));
			elecContBeneAcctDtlMapper.delete(map);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "add 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return backInfo;
}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public ElecContBeneAcctDtlBo findById(String id){
		ElecContBeneAcctDtlEntity entity=null;
		ElecContBeneAcctDtlBo bo=null;
		try{
			entity=(ElecContBeneAcctDtlEntity)elecContBeneAcctDtlMapper.findById(id);
		if(!StringUtil.isNullOrEmpty(entity)){
				bo=ElecContBeneAcctDtlBo.entityToBo(entity);
			}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
	}
		return bo;
	}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public ElecContBeneAcctDtlBo findByMap(Map queryMap){
		ElecContBeneAcctDtlEntity entity=null;
		ElecContBeneAcctDtlBo bo=null;
		try{
			entity=(ElecContBeneAcctDtlEntity)elecContBeneAcctDtlMapper.get(queryMap);
			if(!StringUtil.isNullOrEmpty(entity)){
				bo=ElecContBeneAcctDtlBo.entityToBo(entity);
			}
		}catch(Exception e){
			BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return bo;
}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public ElecContBeneAcctDtlBo findByBo(ElecContBeneAcctDtlBo param){
		ElecContBeneAcctDtlEntity entity=null;
		ElecContBeneAcctDtlBo bo=null;
		try{
			entity=(ElecContBeneAcctDtlEntity)elecContBeneAcctDtlMapper.findByBo(param);
			if(!StringUtil.isNullOrEmpty(entity)){
				bo=ElecContBeneAcctDtlBo.entityToBo(entity);
			}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return bo;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public List<ElecContBeneAcctDtlBo> findAllList(ElecContBeneAcctDtlBo map){
		List<ElecContBeneAcctDtlBo> boList=new ArrayList<ElecContBeneAcctDtlBo>();
		List<ElecContBeneAcctDtlEntity> entityList=new ArrayList<ElecContBeneAcctDtlEntity>();
		try{
					entityList=elecContBeneAcctDtlMapper.findAllList( map);
				for(int i=0;i<entityList.size();i++){
					ElecContBeneAcctDtlEntity entity=entityList.get(i);
					ElecContBeneAcctDtlBo bo=ElecContBeneAcctDtlBo.entityToBo(entity);
					boList.add(bo);
				}
		}catch(Exception e){
				BaseLog.e(this.getClass(), "findAllList 查询失败", e);
				throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public List<ElecContBeneAcctDtlBo> findAllList(Map<String,Object> map){
		List<ElecContBeneAcctDtlBo> boList=new ArrayList<ElecContBeneAcctDtlBo>();
		List<ElecContBeneAcctDtlEntity> entityList=new ArrayList<ElecContBeneAcctDtlEntity>();
		try{
				entityList=elecContBeneAcctDtlMapper.findAllList( map);
			for(int i=0;i<entityList.size();i++){
				ElecContBeneAcctDtlEntity entity=entityList.get(i);
				ElecContBeneAcctDtlBo bo=ElecContBeneAcctDtlBo.entityToBo(entity);
				boList.add(bo);
			}
		}catch(Exception e){
			BaseLog.e(this.getClass(), "findAllList 查询失败", e);
		throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public List<ElecContBeneAcctDtlBo> findAllListPage(ElecContBeneAcctDtlBo param){
		List<ElecContBeneAcctDtlBo> boList=new ArrayList<ElecContBeneAcctDtlBo>();
		List<ElecContBeneAcctDtlEntity> entityList=new ArrayList<ElecContBeneAcctDtlEntity>();
		try{
		entityList=elecContBeneAcctDtlMapper.findAllListPage(param);
			for(int i=0;i<entityList.size();i++){
				ElecContBeneAcctDtlEntity entity=entityList.get(i);
				ElecContBeneAcctDtlBo bo=ElecContBeneAcctDtlBo.entityToBo(entity);
				boList.add(bo);
		}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findAllList 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Wed Aug 28 17:25:21 CST 2019
	*/
	public int count(ElecContBeneAcctDtlBo bo){
		int count=0;
		try{
			    ElecContBeneAcctDtlEntity entity=ElecContBeneAcctDtlBo.boToEntity(bo);
			    count=(Integer)elecContBeneAcctDtlMapper.count(entity);
			}catch(Exception e){
				 BaseLog.e(this.getClass(), "findById 查询失败", e);
				 throw new BaseException("查询！",e);
			}
		return count;
	}
}

